package jue;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Call {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable callable = new Callable() {
            @Override
            public Object call() throws Exception {
                for (int i = 0; i <100 ; i++) {
                    System.out.println(Thread.currentThread().getName()+":"+i);
                    Thread.sleep(100);
                }
                return "Callable接口的call方法的返回值";
            }
        };
        FutureTask futureTask = new FutureTask(callable);
        new Thread(futureTask).start();
        System.out.println("等待......");
        Object o = futureTask.get();
        System.out.println(o);
    }
}
